<template>
  <div class="contain">
    <div class="title">
      <el-row :gutter="20">
        <el-col :span="6">
          <div class="bufen">
            <p>
              <span>【题型】:{{ getDiffculty(list.questionType) }}</span>
            </p>
          </div>
        </el-col>
        <el-col :span="6">
          <div class="bufen">
            <p>
              <span>【编号】:{{ list.id }}</span>
            </p>
          </div></el-col
        >
        <el-col :span="6">
          <div class="bufen">
            <p>
              <span>【难度】:{{ getDocument(list.difficulty) }}</span>
            </p>
          </div></el-col
        >
        <el-col :span="6">
          <div class="bufen">
            <p>
              <span>【标签】:{{ list.tags }}</span>
            </p>
          </div></el-col
        >
      </el-row>
      <el-row :gutter="20">
        <el-col :span="6">
          <div class="bufen">
            <p>
              <span>【学科】:{{ list.subjectName }}</span>
            </p>
          </div>
        </el-col>
        <el-col :span="6">
          <div class="bufen">
            <p>
              <span>【目录】:{{ list.directoryName }}</span>
            </p>
          </div></el-col
        >
        <el-col :span="6">
          <div class="bufen">
            <p>
              <span>【方向】:{{ list.directory }}</span>
            </p>
          </div></el-col
        >
      </el-row>
    </div>
    <div class="body" v-if="list.difficulty == 1">
      <p>[题干]:</p>
      <p v-html="list.question"></p>
      <p>单选题 选项:(以下选中的选项为正确答案)</p>
      <el-radio-group v-model="radio">
        <el-radio
          disabled
          :label="item.isRight"
          v-for="(item, index) in list.options"
          :key="index"
          >{{ item.title }}</el-radio
        >
      </el-radio-group>
    </div>
    <div class="body" v-if="list.difficulty == 3">
      <p>[题干]:</p>
      <p v-html="list.question"></p>
      <p>多选题 选项:(以下选中的选项为正确答案)</p>
      <el-radio-group v-model="radio">
        <el-radio
          disabled
          :label="item.isRight"
          v-for="(item, index) in list.options"
          :key="index"
          >{{ item.title }}</el-radio
        >
      </el-radio-group>
    </div>
    <div class="body" v-if="list.difficulty == 2">
      <p>[题干]:</p>
      <p v-html="list.question"></p>
    </div>
    <div class="footer">
      <div class="h1">
        <p>【参考答案】:</p>
        <el-button type="danger" size="mini" @click="show=true">视频答案阅览</el-button>
      </div>
      <video width="320" height="240" controls v-show="show">
        <source :src="list.videoURL" type="video/mp4" />
        您的浏览器不支持 video 标签。
      </video>
      <div class="h1">
        <span>【答案解析】:</span>
        <p v-html="list.answer"></p>
      </div>
      <div class="h1">
        <p>【题目备注】:{{ list.remarks }}</p>
      </div>
    </div>
  </div>
</template>


<script>
import { detail } from "@/api/hmmm/questions.js";
import { questionType, difficulty, direction } from "@/api/hmmm/constants.js";
export default {
  props: ["data"],
  data() {
    return {
      list: [],
      radio: 1,
      show:false
    };
  },
  async created() {
    console.log(this.data.id);
    let res = await detail({
      id: this.data.id,
    });
    this.list = res.data;
    console.log(this.list);
  },
  methods: {
    getDiffculty(item1) {
      questionType.forEach((item) => {
        if (item.value == item1) {
          item1 = item.label;
        }
      });
      return item1;
    },
    getDocument(item1) {
      difficulty.forEach((item) => {
        if (item.value == item1) {
          item1 = item.label;
        }
      });
      return item1;
    },
  },
};
</script>

<style scoped lang='less'>
.contain {
  width: 100%;
  height: 500px;
  padding: 20px 30px;
  .title {
    height: 150px;
    .bufen {
      width: 150px;
      height: 50px;
    }
  }
  .body {
    height: 120px;
  }
  .footer {
    height: 200px;
    .h1 {
      margin-top: 10px;
      height: 30px;
      display: flex;
      align-items: center;
    }
  }
}
</style>
